<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />

<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>老师密码修改</title>
</head>
<script type="text/javascript">
$(function() {

	//-----------确认旧密码--------------------
	$("input",$("#user_current_password").next("span")).blur(function(){
		var upsw =${sessionScope.User.upsw};
		var oldpsw = $("#user_current_password").val();
		if(oldpsw!=upsw){
		    	$("#psw").show();
		    	$("#sve").linkbutton({ 
		    		disabled:true
		    	})
		}else{
			$("#psw").hide();
			$("#sve").linkbutton({ 
	    		disabled:false
	    	})
		}
	    })
	    
	//-----------判断新旧密码是否一致--------------------
	$("input",$("#user_new_password").next("span")).blur(function(){
		var newpsw = $("#user_new_password").val();
		var upsw =${sessionScope.User.upsw};
		if(newpsw==upsw){
		    	$("#npsw").show();
		    	$("#sve").linkbutton({ 
		    		disabled:true
		    	})
		}else{
			$("#npsw").hide();
			$("#sve").linkbutton({ 
	    		disabled:false
	    	})
		}
	    })
	    
	//-----------确认新密码--------------------
	$("input",$("#user_qr_password").next("span")).blur(function(){
		var newpsw = $("#user_new_password").val();
		var rnewpsw = $("#user_qr_password").val();	
		if(newpsw!=rnewpsw){
		    	$("#newpsw").show();
		    	$("#sve").linkbutton({ 
		    		disabled:true
		    	})
		}else{
			$("#newpsw").hide();
			$("#sve").linkbutton({ 
	    		disabled:false
	    	})
		}
	    })
	   
	
	//--------------提交新密码--------------
	$('#sve').linkbutton({    
		onClick:function(){
			var upsw =${sessionScope.User.upsw};
			var oldpsw = $("#user_current_password").val();
			var newpsw = $("#user_new_password").val();
			var rnewpsw = $("#user_qr_password").val();	
			if(oldpsw==upsw&&newpsw==rnewpsw){
				$.ajax({
						url:'updeTeacherpsw',
						type:'post',
						data:{'newupsw1':newpsw},
						dataType:'text',
						success:function(xx){
							if(xx=="0"){
								$.messager.alert('error','修改失败！','info');
							}else{
								$.messager.show({
									title:'消息',
									msg:'密码修改成功',
									showType:'slide'
								});						
							}						
						}
						})
			}else{
				$.messager.alert('error','密码认证失败！','info');
			}	
		}
	})
	
})
</script>
<body>
<div>

<label for="user_current_password">当前密码</label><br>
<input class="easyui-textbox" id="user_current_password" name="user[current_password]" placeholder="oldpassword" required="required" type="password">
<span id="psw"  style="font-size:xx-small;display:none;">密码错误!</span>
<br><br>
<label for="user_new_password">新密码</label><br>
<input class="easyui-textbox" id="user_new_password" name="user[new_password]" placeholder="newpassword" required="required" type="password">
<span id="npsw"  style="font-size:xx-small;display:none;">新旧密码一致!</span>
<br><br>
<label for="user_qr_password">确认密码</label><br>
<input class="easyui-textbox" id="user_qr_password" name="user[queren_password]" placeholder="newpassword" required="required"  type="password" >
<span id="newpsw"  style="font-size:xx-small;display:none;">密码不一致!</span>
<br><br>

<button id="sve"  class="easyui-linkbutton"  iconcls="icon-save">确认修改</button>


</div>
</body>
</html>